﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Consulta.Core;
using System.Data;
using Softpro.AccesoDatosDB2;

namespace Consulta.Manager
{
    public class MEgreso
    {
        public Egreso consultarID(string pLibDatos, int pNumeComp)
        {
            try
            {
                accesoDatos p = new accesoDatos();
                string tSql = "SELECT T1.EgrFch, " +
                        " T1.EgrDsn," +
                        " T1.EgrNit," +
                        " T1.EgrNdc," +
                        " T1.EgrTipPag," +
                        " T1.EgrSts," +
                        " T2.CtcDsc " +
                        " FROM " + pLibDatos + ".EGRBAS T1" +
                        " JOIN " + pLibDatos + ".CTCBAS T2 ON " +
                        " (T1.EgrEfn = T2.CtcEfn " +
                        " AND T1.EgrCtc = T2.CtcCtc) " +
                        " WHERE T1.EgrCmp = " + pNumeComp;
                DataTable tTabla = p.leerDatosSQL(tSql);
                Egreso tEgreso = new Egreso();
                //Asignar valores del registro
                DataRow tFila = tTabla.Rows[0];
                tEgreso.EgrCmp = pNumeComp;
                tEgreso.EgrFch = tFila["EgrFch"].ToString();
                tEgreso.EgrDsn = tFila["EgrDsn"].ToString();
                tEgreso.EgrNit = Convert.ToInt32(tFila["EgrNit"]);
                tEgreso.EgrTipPag = tFila["EgrTipPag"].ToString();
                tEgreso.EgrSts = tFila["EgrSts"].ToString();
                tEgreso.EgrCta = tFila["CtcDsc"].ToString();
                return tEgreso;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }
}
